// Lang_19 [arrays (single dimension)].nova // The application class. class ArraysSingleDimensionApp { // Array of Integers static attribute. private static int[] j; // Application class's "main" function. public static void main( String[] args ) { // Declare and create a new "ArrayClass" object. ArrayClass arrayClass = new ArrayClass( ); // Populate the static attribute using the "arrayClass" object. j = arrayClass.getArray( ); // Output the static attribute array. Stream.writeLine( "The length of array j = " + UInteger.toString( j.length ) ); for ( uint loopIndex = 0; loopIndex < j.length; loopIndex++ ) { Stream.writeLine( "element " + UInteger.toString( loopIndex ) + " = " + Integer.toString( j[ loopIndex ] ) ); } // Create a new array using the "new" keyword. int[] newArray = new int[ 3 ]; // Populate the new array. newArray[ 0 ] = 1000; newArray[ 1 ] = 2000; newArray[ 2 ] = 3000; // Output the new array. Stream.writeLine( "\nThe length of array newArray = " + UInteger.toString( newArray.length ) ); for ( uint loopIndex = 0; loopIndex < newArray.length; loopIndex++ ) { Stream.writeLine( "element " + UInteger.toString( loopIndex ) + " = " + Integer.toString( newArray[ loopIndex ] ) ); } } } class ArrayClass { // Array instance attribute. private int[] attrArray; // Constructor method. public ArrayClass( ) { // Initialize the instance attribute. attrArray = { 10, 11, 12, 13, 14 }; } // Accessor method for the instance attribute. public int[] getArray( ) { // Return a reference to the instance attribute. return attrArray; } }